import request from './request'
//获取轮播图数据请求
export const getBannerListData = () => {
  return request({url:'/mall-api/index/findBanner'})
}

//获取首页导航数据请求
export const getNavListData = () => {
  return request({url:'/mall-api/index/findCategory1'})
}

//猜你喜欢数据请求
export const getYouLikeListData = () => {
  return request({url:'/mall-api/index/findListGoods'})
}

//人气推荐数据请求
export const getRecommendListData = () => {
  return request({
    url:'/mall-api/index/findRecommendGoods'
  })
}

//category-获取左侧导航项数据
export const reqGetCategoryNavListData = () => {
  return request({url:'/mall-api/index/findCategoryTree'})
}

//商品列表中的数据
export const reqGetMoreGoodsListData = ({page,limit,...rest}) => {
  return request({url:`/mall-api/goods/list/${page}/${limit}`,data:rest})
}

//向后端服务器发送请求，获取token
export const reqGetTokenByCode = (code) => {
  return request({url:`/mall-api/weixin/wxLogin/${code}`})
}

//获取用户信息
export const reqGetUserInfo = () => {
  return request({url:'/mall-api/weixin/getuserInfo'})
}

//更改用户信息
export const reqUpdateUserInfo = (userInfo) => {
  return request({
    url:`/mall-api/weixin/updateUser`,
    method:'post',
    data:userInfo
  })
}

//获取商品详情
export const reqGetGoodsDetail = (goodsId) => {
  return request({url:`/mall-api/goods/${goodsId}`})
}

//加入购物车
export const reqAddToCart = ({goodsId,count,blessing}) => {
  return request({url:`/mall-api/cart/addToCart/${goodsId}/${count}`,data:{blessing}})
}

//获取购物车列表数据
export const reqGetCartListData = () => {
  return request({url:'/mall-api/cart/getCartList'})
}

//购物车单选
export const reqHandleChangeChecked = ({goodsId,isChecked}) => {
  return request({url:`/mall-api/cart/checkCart/${goodsId}/${isChecked}`})
}
//购物车全选
export const reqHandleChangeAllChecked = (isChecked) => {
  return request({url:`/mall-api/cart/checkAllCart/${isChecked}`})
}

//删除购物车商品
export const reqDeleteGoods = (goodsId) => {
  return request({url:`/mall-api/cart/delete/${goodsId}`})
}

//获取订单地址
export const reqGetOrderAddress = () => {
  return request({url:`/mall-api/userAddress/getOrderAddress`})
}

//订单之立即购买获取数据
export const reqGetOrderDetailByBuyNow = ({goodsId,blessing}) => {
  return request({url:`/mall-api/order/buy/${goodsId}`,data:{blessing}})
}

//去结算获取购物车商品列表
export const reqGetCartgoodsTrad = () => {
  return request({url:`/mall-api/order/trade`})
}

//立即购买获取商品信息
export const reqGetGoodsInfoBuyNow = ({goodsId,blessing}) => {
  return request({url:`/mall-api/order/buy/${goodsId}`,data:{blessing}})
}

//新增地址
export const reqAddUserAddressInfo = (userAddress) => {
  return request({url: `/mall-api/userAddress/save`,data: userAddress,method: 'post'})
}

//获取地址列表数据
export const reqGetUerAddressList = () => {
  return request({url:`/mall-api/userAddress/findUserAddress`})
}

//根据id获取一条地址信息
export const reqGetUserAddressInfoById = (id) => {
  return request({
    url: `/mall-api/userAddress/${id}`
  })
}

//更新用户地址请求
export const reqUpdateUserAddressInfo = (params) => {
  return request({
    url: `/mall-api/userAddress/update`,
    data: params,
    method: 'post'
  })
}

//去结算请求
export const reqSubmitOrder = (params) => {
  return request({
    url: '/mall-api/order/submitOrder',
    data: params,
    method: 'post'
  })
}

//获取支付参数
export const reqGetPaymentParams = (orderNo)=>{
  return request({url:`/mall-api/webChat/createJsapi/${orderNo}`})
}

//查询订单支付结果
export const reqGetPayStatus =(orderNo)=>{
  return request({url:`/mall-api/webChat/queryPayStatus/${orderNo}`})
}

//商品订单列表
export function orderList({ page, limit }) {
  return request({
    url: `/mall-api/order/order/${page}/${limit}`
  });
}